#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    int arr[10][10];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int max = arr[0][0];
    int min = arr[0][0];
    for (int i = 0; i < n; i++)
    {
        if (arr[i][i] > max)
        {
            max = arr[i][i];
        }
        if (arr[i][i] < min)
        {
            min = arr[i][i];
        }
    }
    for (int i = 0; i < n; i++)
    {
      
            if (arr[i][n-1-i] > max)
            {
                max = arr[i][n-1-i];
            }
            if (arr[i][n-1-i] < min)
            {
                min = arr[i][n-1-i];
            }
    }
    printf("%d %d", max, min);
    return 0;
}